<%--
  Created by IntelliJ IDEA.
  User: 22531
  Date: 2021/6/9
  Time: 19:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript">
        $(function (){
            $('#clazzJoinCourse').datagrid({
                url:'/admin/getAllCourseByRequired',
                title:'本年度必修课程',
                columns:[[
                    {field:'id',title:'ID',align:'center'},
                    {field:'name',title:'课程名称',align:'center'},
                    {field:'place',title:'上课地点',align:'center'},
                    {field:'c_year',title:'年度',align:'center'},
                    {field:'tea_name',title:'上课老师',align:'center'},
                    {field:'c_type',title:'课程类型',align:'center'},
                ]],
                rownumbers:true,
                pagination: true,
                pageSize:10,
                pageList:[10,20,30,40,50],
                singleSelect: true,
            });

            $('#clazz').datagrid({
                url: '/admin/getAllClazz',
                columns:[[
                    {field:'id',title:'ID',align:'center'},
                    {field:'name',title:'班级名称',align:'center'},
                    {field:'dept',title:'学院',align:'center'},

                ]],
                rownumbers:true,
                pagination: true,
                pageSize:10,
                pageList:[10,20,30,40,50],
                singleSelect: true,
                title:'班级',

                // onClickCell:onClickCell,
            });

            $('#cc').datagrid({
                url: '/admin/getAllCC',
                columns:[[
                    {field:'id',title:'ID',align:'center'},
                    {field:'clazz_id',title:'班级id',align:'center'},
                    {field:'course_id',title:'课程id',align:'center'},
                    {field:'now_count',title:'目前加入课程人数',align:'center'},
                    {field:'real_count',title:'该班总人数',align:'center'},

                ]],
                rownumbers:true,
                pagination: true,
                pageSize:10,
                pageList:[10,20,30,40,50],
                singleSelect: true,
                title:'班级选课表',

                // onClickCell:onClickCell,
            });

        })
    </script>
</head>
<body>
<div class="easyui-accordion" style="width:auto;height:auto;">
    <div title="本年度必修课程" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
        <table id="clazzJoinCourse" class="easyui-datagrid"></table>
    </div>

    <div title="班级" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
        <table id="clazz" class="easyui-datagrid"></table>
    </div>

    <div title="班级选课表" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
        <table id="cc" class="easyui-datagrid"></table>
    </div>

</div>
<br>
<div>
    <form id="ff" method="post" action="/admin/clazzJoinCourse" class="easyui-form">
        <div style="margin-bottom:10px;text-align: center" >

            <input class="easyui-numberbox" name="clazz_id" style="width:200px" data-options="prompt:'请输入班级ID',required:true">
        </div>
        <div style="margin-bottom:10px;text-align: center" >

            <input class="easyui-numberbox" name="course_id" style="width:200px" data-options="prompt:'请输入课程ID',required:true">
        </div>

        <div style="text-align:center;margin-bottom:10px">
            <input type="submit" value="加入" class="easyui-linkbutton" onclick="join()" style="width:80px;height:30px">
        </div>
    </form>

</div>

<script type="text/javascript">
    function join() {
        $('#ff').form({
            success:function(data){
                var data = eval('(' + data + ')');
                if(data.msg==false){
                    alert("加入失败"+data.error)
                }else {
                    alert("加入成功");
                }
            }
        });
    }
</script>
</body>
</html>
